proc pr_init_addBUMP {} {
    loadLefFile /projects/tacoma6/workspace/xjsun/chip_top/innovus/datain/LEF/PAD.lef
}

proc pr_addBump_h {} {
    set phy_box_llx [dbget selected.box_llx]
    set phy_box_lly [dbget selected.box_lly]

    set bump_1_x 98.0
    set bump_1_y 20.16

    set bump_2_x 32.0
    set bump_2_y 60.48

    for {set a 0} {$a < 7} {incr a} {
        for {set b 0} {$b < 5} {incr b} {
            set bump_x [expr $bump_1_x+132*$b]
            set bump_y [expr $bump_1_y+80.64*$a]

            set bump_x [expr $bump_x+$phy_box_llx]
            set bump_y [expr $bump_y+$phy_box_lly]

            puts "$bump_x $bump_y"
            set timestamp [clock microseconds]

            #addInst -cell PAD -inst bump_${timestamp} -loc {$bump_x $bump_y} -ori R0 -physical -place_status fixed
            create_bump -cell PAD -loc $bump_x $bump_y -ori R0 -loc_type cell_center -name_format bump_${timestamp}
        }
    }


    for {set a 0} {$a < 7} {incr a} {
        for {set b 0} {$b < 5} {incr b} {
            set bump_x [expr $bump_2_x+132*$b]
            set bump_y [expr $bump_2_y+80.64*$a]

            set bump_x [expr $bump_x+$phy_box_llx]
            set bump_y [expr $bump_y+$phy_box_lly]

            puts "$bump_x $bump_y"
            set timestamp [clock microseconds]

            #addInst -cell PAD -inst bump_${timestamp} -loc {$bump_x $bump_y} -ori R0 -physical -place_status fixed
            create_bump -cell PAD -loc $bump_x $bump_y -ori R0 -loc_type cell_center -name_format bump_${timestamp}
        }
    }
}

proc pr_addBump_v {} {
    set phy_box_llx [dbget selected.box_llx]
    set phy_box_lly [dbget selected.box_lly]

    set bump_1_x 60.021
    set bump_1_y 153.964

    set bump_2_x 20.007
    set bump_2_y 219.964

    for {set a 0} {$a < 5} {incr a} {
        for {set b 0} {$b < 7} {incr b} {
            set bump_x [expr $bump_1_x+80.64*$b]
            set bump_y [expr $bump_1_y+132*$a]

            set bump_x [expr $bump_x+$phy_box_llx]
            set bump_y [expr $bump_y+$phy_box_lly]

            puts "$bump_x $bump_y"
            set timestamp [clock microseconds]

            #addInst -cell PAD -inst bump_${timestamp} -loc {$bump_x $bump_y} -ori R0 -physical -place_status fixed
            create_bump -cell PAD -loc $bump_x $bump_y -ori R0 -loc_type cell_center -name_format bump_${timestamp}
        }
    }


    for {set a 0} {$a < 5} {incr a} {
        for {set b 0} {$b < 7} {incr b} {
            set bump_x [expr $bump_2_x+80.64*$b]
            set bump_y [expr $bump_2_y+132*$a]

            set bump_x [expr $bump_x+$phy_box_llx]
            set bump_y [expr $bump_y+$phy_box_lly]

            puts "$bump_x $bump_y"
            set timestamp [clock microseconds]

            #addInst -cell PAD -inst bump_${timestamp} -loc {$bump_x $bump_y} -ori R0 -physical -place_status fixed
            create_bump -cell PAD -loc $bump_x $bump_y -ori R0 -loc_type cell_center -name_format bump_${timestamp}
        }
    }
}

proc pr_addBump_core {} {
    # 8700x8000
    create_bump -cell PAD -loc 820.0 820.0 -loc_type cell_center -orientation R0 -pattern_array {43 48} -pitch {150 150}
    create_bump -cell PAD -loc 895.0 895.0 -loc_type cell_center -orientation R0 -pattern_array {43 48} -pitch {150 150}
}

proc pr_addBump_one {x y name} {
    create_bump -cell PAD -loc $x $y -loc_type cell_center -orientation R0 -name_format "I_%i_${name}"  -return_bumps_name
}

proc pr_addBump_PCIE {box name} {
    set bump_x [expr ([lindex $box 0]+[lindex $box 2])/2]
    set bump_y [expr ([lindex $box 1]+[lindex $box 3])/2]
    
    pr_addBump_one $bump_x $bump_y $name
}